//
//  GeneralMagager.m
//  HaoDeCaiFu
//
//  Created by 张玉鹏 on 2017/11/18.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "GeneralMagager.h"

@implementation GeneralMagager

+(BOOL)justIslogin
{
    NSUserDefaults*defults=[NSUserDefaults standardUserDefaults];
    NSString*token=[defults objectForKey:@"Token"];
    [defults synchronize];
    
    if (token) {
        return YES  ;
    }
    else
    {
        return NO;
    }
}

//判断是否为整形：
+ (BOOL)isPureInt:(NSString*)string{
    NSScanner* scan = [NSScanner scannerWithString:string];
    int val;
    return[scan scanInt:&val] && [scan isAtEnd];
}

//判断是否为浮点形：

+ (BOOL)isPureFloat:(NSString*)string{
    NSScanner* scan = [NSScanner scannerWithString:string];
    float val;
    return[scan scanFloat:&val] && [scan isAtEnd];
}

+(NSString*)createLiuShuiHao
{
    NSDateFormatter*formartter=[[NSDateFormatter alloc]init];
    [formartter setDateFormat:@"YYYYMMDD"];
    NSString*dateStr=[formartter stringFromDate:[NSDate date]];
    
    NSInteger suijiFive = (10000 + (arc4random() % (99999-10000 + 1)));
    
    NSString*liushuihao=[NSString stringWithFormat:@"ZHD%@%lu",dateStr,suijiFive];
    return liushuihao;
}

//时间戳转化为时间
+(NSString*)shijianChuoZhuanshijianWith:(NSString*)TimeStr
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"YYYY-MM-dd"];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[TimeStr doubleValue] / 1000];
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    return confromTimespStr;
    
}


@end
